﻿--[[
   @brief    initialization for ui, is loaded and executed by c++ module when tgp startups
   @author   sogoodchen
   @version  1.0
   @date     2015-03-09
--]]

function exception_callback(ori_err)
    lua_excepton_qos_report(ori_err);
    local ret = '==============\n'.. ori_err .. '\n==============\n' .. debug.traceback();
    return ret;
end

function crash_callback(temp_dir)
  local date_str = os.date("%Y%m%d%H%M%S");
  local file_name = temp_dir.."\\LuaInfo"..date_str..".txt";
  local file_obj = ierd_tgp.common.LuaFileObject:new();
  if nil == file_obj then
    return file_name;
  end
  if file_obj:open(file_name, "w") then
    local traceback = debug.traceback();
    file_obj:write(traceback, traceback:len());
    file_obj:close();
  end
  file_obj:delete();
  return file_name;
end

ierd_tgp.tpf_ui.Require("common\\base_utility.lua");  
ierd_tgp.tpf_ui.Require("common\\game_utility.lua");
ierd_tgp.tpf_ui.Require("common\\ui_utility.lua");
ierd_tgp.tpf_ui.Require("common\\web_utility.lua");
ierd_tgp.tpf_ui.Require("common\\animation_utility.lua");
ierd_tgp.tpf_ui.Require("common\\bit_operation_utility.lua");
ierd_tgp.tpf_ui.Require("common\\shadow_helper.lua");
ierd_tgp.tpf_ui.Require("common\\red_dot_helper.lua");
-- ierd_tgp.tpf_ui.Require("utility.lua");
ierd_tgp.tpf_ui.Require("layout_mgr.lua");
ierd_tgp.tpf_ui.Require("custom_ids.lua");
ierd_tgp.tpf_ui.Require("event_ids.lua");
ierd_tgp.tpf_ui.Require("event_center.lua");
ierd_tgp.tpf_ui.Require("desc_mgr.lua");
ierd_tgp.tpf_ui.Require("web_register_center.lua");
ierd_tgp.tpf_ui.Require("plugin_forward.lua");
ierd_tgp.tpf_ui.Require("tqos\\tqos.lua");
ierd_tgp.tpf_ui.Require("TPFLocalization.lua");
ierd_tgp.tpf_ui.Require("game_id.lua");
ierd_tgp.tpf_ui.Require("Common\\tgp_log.lua");
ierd_tgp.tpf_ui.Require("common\\xmlSimple.lua");
ierd_tgp.tpf_ui.Require("product_mgr.lua");
ierd_tgp.tpf_ui.Require("lua_plugin_mgr.lua");
ierd_tgp.tpf_ui.Require("lua_test.lua");

--公共弹窗tips组件
ierd_tgp.tpf_ui.Require("poptips_data.lua");
ierd_tgp.tpf_ui.Require("poptips\\control.lua");
ierd_tgp.tpf_ui.Require("poptips\\desc.lua");

function init_ui()  
    base_utility.log("init_ui.");
    layout_mgr.restore_root_layout();
    -- ierd_tgp.tpf_ui.LoadDesc();
    -- desc_mgr.work();
    comm_center.send_broadcast("brdcst_before_login", {});
end

function lua_excepton_qos_report(err)
  local qos_param = ierd_tgp.tpf_ui.LuaQosData:new();
  qos_param.oc_type = ierd_tgp.tpf_ui.kInstant;
  qos_param.qos_report_id = ierd_tgp.adapt_for_imports.qos.Qos_kind.kLuaErrReport;
  qos_param.str_val1 = err;
  qos_param.str_val2 = package.path;
  qos_param.int_count = 0;
  qos_param.str_count = 2;
  base_utility.lua_qos(qos_param);
  qos_param:delete();
end


init_ui();
